import scala.collection.mutable.ArrayBuffer

/**
 * Created by Administrator on 2015/12/27 0027.
 */
object data_struct {
  def main(args: Array[String]) {
    print("hello scala");
    val one = 15
    val two = 0xabc
    val four = 1.3e5
    val six = 1.2f
    val right = true
    val a = 'A'

    if (2 > 3) print(222) else print(333)

    var m = 10

    println()
    for (i <- 1 to 10) print(i)
    println()
    for (i <- 1 until 10) print(i)
    println()
    for (i <- 1 to 10) if (i % 2 == 0) print(i)
    println()
    for (i <- 1 to 10; if (i % 2 == 0)) print(i)
    println()
    for (i <- 1 to 4; j <- 1 to 4) print(i + j)
    println()
    val No = for (i <- 1 to 4) yield i
    println()
    val sign = 2 match {
      case 2 => 222;
      case 3 => 333
    }
    println()
    val name = readLine("your name: \n")
    val age = readInt()
    val addr = readDouble()

    val A = new Array[Int](8)
    val B = Array(1, 2, 3, 4, 5)

    val C = new ArrayBuffer[Int]()
    C += 12
    C += 34
    C +=(23, 34)
    C ++= Array(12, 3, 4, 5)
    C.trimEnd(1)
    C.insert(2, 344, 34, 5, 5, 6, 77)
    C.remove(3, 3)
    val D = C.toArray
    val E = D.toBuffer

    for (i <- C) println(i)

    for (i <- 0 to C.length - 1) println(C(i))

    for (i <- 0 to(C.length - 1, 2)) println(C(i))

    println()
    for (i <- (0 to C.length - 1).reverse) println(C(i))


    val Z = Map('a' -> 2, 'b' -> 3, 'c' -> 4)
    val ZZ = Map(('a', 2), ('b', 3), ('c', 3))

    val Y = scala.collection.mutable.Map(('a', 2), ('b', 3))


    Y('d') = 4
    Y +=(('f', 3), ('g', 3))
    Y -= 'a'

    val W = Z + ('m' -> 4)

    val aa = Z('a')
    val c = Z.contains('a')
    val d = Z.getOrElse(3, 0)

    for ((i, j) <- Z) println(i)

    val e = Z.keySet
    val f = Z.values

    val g = (1, 2, 3, 4, 'd', 1.2)
    val h = g._1

    val aaa = Array(1, 2, 3, 4)
    val bbb = Array('a', 'b', 'c')
    val ccc = aaa zip bbb
    val ddd = aaa.zip(bbb).toMap

  }

  def add(m: Int, n: Int) = m + n;

  def min(x: Int, y: Int) = if (x > y) y else x

}
